template.defaults.imports.TimestampToTime = function (timestamp) {
    var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = date.getDate() + ' ';
    var h = date.getHours() + ':';
    var m = date.getMinutes() + ':';
    var s = date.getSeconds();
    return Y + M + D + h + m + s;
};
initData();
/* global myOrderId*/
/* global getCookie*/
/* global template*/
function initData(){
    $.get('/antique/api/mallOrder/query', { id:myOrderId,token:getCookie('token') }, function (result) {
       if (result.code == 0){
           var data = result.data;
            document.getElementById('contentTo').innerHTML = template('content', data);  

       }
    });
}
function logisticeDetail(){
    $(".topReturn").hide();
    $("#select_logistics_detail").popup();
}
function getlogistics(expCode,expNo){
    $.get('/antique/api/logistics/query_logistics', { expCode:expCode,expNo:expNo }, function (result) {
        if (result.code == 0){
            var data = result.data;
            var list = data.Traces;
            if (list.length > 0) {
                $("#odetail-express-desc").html(list[list.length - 1].AcceptStation );
                $("#oderail-express-time").html(list[list.length - 1].AcceptTime );
            }
            
            document.getElementById('contentLogisticsTo').innerHTML = template('contentLogistics', data);
        }
     });
}

function cancelRefund (orderId) {
    $.confirm("您是否确认取消退款？", "", function() {
        $.post('/antique/api/mallOrder/user/order_refund_cancel', { id:orderId,token:getCookie('token') }, function (result) {
            if (result.code == 0) {
                $.toast("操作成功！");
                if(isMiniProgram()){
                    wx.miniProgram.navigateBack();
                } else {
                    goPreUrl();
                }
            } else {
                $.toast(result.message, "cancel");
            }
         });
      }, function() {
        //取消操作
      });
    
}

function opRefund (orderId,type) {
    $.confirm("您是否确认该操作？", "", function() {
        $.post('/antique/api/mallOrder/shop/order_refund_audit', { id:orderId,token:getCookie('token'),oper:type }, function (result) {
            if (result.code == 0) {
                $.toast("操作成功！");
                if(isMiniProgram()){
                    wx.miniProgram.navigateBack();
                } else {
                    goPreUrl();
                }
            } else {
             $.toast(result.message, "cancel");
            }
         });
      }, function() {
        //取消操作
      });
    
}


